home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
.net 2002 March
/
DotNetMagazine-Issue107-Coverdisc-NET107-02-03-PCMac.bin
/
pc
/
PC Software
/
free_browsing
/
DavesQckSearchDbar3-14
/
dqsd.exe
/
categoryExpander.htc
< prev
next >
Wrap
Text File
|
2002-06-07
|
3KB
|
89 lines
<attach event="onclick" handler="doClick"/>
<attach event="onreadystatechange" handler="onReadyStateChange"/>
<property name="category"/>
<property name="type"/>
<script language="JScript">
function onReadyStateChange()
{
var el = event.srcElement;
if ( type )
{
el.title = (type == 'expandall' ? 'Expand all category groupings. (Very helpful if searching this window.)' : 'Collapse all category groupings');
return;
}
el.innerText = '[-]';
el.title = 'Collapse list of searches for this category';
doClick();
var elTable = el.parentElement;
while ( elTable && elTable.tagName != 'TABLE' )
elTable = elTable.parentElement;
elTable = elTable.parentElement;
while ( elTable && elTable.tagName != 'TBODY' )
elTable = elTable.parentElement;
var elCount = el.parentElement.all('categoryCount');
var rows = elTable.children[ category ];
if ( !rows.length )
rows = new Array(rows); // in case there's only one
var nCount = rows.length;
var nEnabled = 0;
for ( var iSearch = 0; iSearch < nCount; iSearch++ )
{
var toggle = rows[ iSearch ].cells(1).all('search_enabled');
if ( toggle.checked )
nEnabled += 1;
}
elCount.innerText = '(' + nEnabled + '/' + (nCount ? nCount : 1) + ')';
}
function doClick()
{
try
{
var el = event.srcElement;
if ( type )
{
var elBody = el.parentElement;
while ( elBody && elBody.tagName != 'BODY' )
elBody = elBody.parentElement;
var expanders = elBody.all( 'categoryExpander' );
for ( var i = 0; i < expanders.length; i++ )
{
expanders[i].innerText = type == 'expandall' ? '[+]' : '[-]';
expanders[i].fireEvent("onclick");
}
return;
}
var elTable = el.parentElement;
while ( elTable && elTable.tagName != 'TABLE' )
elTable = elTable.parentElement;
elTable = elTable.parentElement;
while ( elTable && elTable.tagName != 'TBODY' )
elTable = elTable.parentElement;
var expand = el.innerText.substring( 0, 3 ) == '[+]';
var rows = elTable.children[ category ];
if ( !rows.length )
rows = new Array( rows );
for ( var i = 0; i < rows.length; i++ )
rows[i].style.display = (expand ? '' : 'none');
el.innerText = '[' + (expand ? '-' : '+') + ']';
el.title = (expand ? 'Collapse' : 'Expand') + ' list of searches for this category';
}
catch ( e )
{
alert( e.description );
}
}
</script>